Skip to content

Conversation

@felixarntz
Copy link
Member

Summary

Addresses issue #1142

Checklist

  • My code is tested and passes existing unit tests.
  • My code has an appropriate set of unit tests which all pass.
  • My code is backward-compatible with WordPress 4.7 and PHP 5.6.
  • My code follows the WordPress coding standards.
  • My code has proper inline documentation.
  • I have signed the Contributor License Agreement (see https://cla.developers.google.com/).

'script_loader_tag',
function ( $tag, $handle ) use ( $assets ) {
if ( $this->context->is_amp() && isset( $assets[ $handle ] ) && $assets[ $handle ] instanceof Script ) {
// TODO: 'hoverintent-js' can be removed from here at some point, see https://github.com/ampproject/amp-wp/pull/3928.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the right PR reference? Perhaps instead ampproject/amp-wp#4001?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is. ampproject/amp-wp#3928 is where you covered hoverintent-js so that it's properly flagged.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see. It's handling cases where users are running older versions of the AMP plugin.

$this->assets[ $handle ]->before_print();

if ( $is_amp && $this->assets[ $handle ] instanceof Script ) {
$this->add_extra_script_amp_dev_mode( $handle );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this should no longer be necessary after ampproject/amp-wp#4001. As long as the dependency has the ampdevmode data added to it, there would be no more need to manually tag such inline scripts for matching a XPath expression.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reminding me of that! I've added two TODOs in the respective areas to remove our own fix in the future.

function ( $tag, $handle ) use ( $assets ) {
if ( $this->context->is_amp() && isset( $assets[ $handle ] ) && $assets[ $handle ] instanceof Script ) {
// TODO: 'hoverintent-js' can be removed from here at some point, see https://github.com/ampproject/amp-wp/pull/3928.
if ( $this->context->is_amp() && ( isset( $assets[ $handle ] ) && $assets[ $handle ] instanceof Script || 'hoverintent-js' === $handle ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't the need to manually check for hoverintent-js made obsolete by ampproject/amp-wp#3928?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes indeed (see above), however this was only in the quite recent 1.4.2 version. We'll keep this around for a bit more to have support for older AMP plugin versions. I'd be curious to see what the AMP plugin version distribution is :)

Copy link
Collaborator

@aaemnnosttv aaemnnosttv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@felixarntz felixarntz merged commit 294c3af into develop Feb 21, 2020
@felixarntz felixarntz deleted the fix/1142-amp-dev-mode branch February 21, 2020 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants